<template>
	<view class="container">
		<view class="code-con">
			<image v-if="invitePath" class="share-code" :src="invitePath" :style="{height: imgInfo + 'rpx'}" :show-menu-by-longpress="{showMenu}" mode="aspectFill"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				invitePath:'',
				showMenu:true,
				imgInfo: ''
			}
		},
		onLoad() {
			// 获取分享二维码及会员信息
			this.getShareCode();
			
			// #ifdef H5
			// 禁止分享
			this.$share({hideShare:true});
			// #endif
		},
		onShow() {
			
		},
		methods: {
			//获取分享二维码
			async getShareCode(){
				let url, comefrom, self = this;
				// #ifdef H5
				url = 'h5/#/pages/index/home';
				comefrom = 'h5';
				// #endif
				// #ifdef MP-WEIXIN
				url = 'pages/index/home';
				comefrom = 'wechat';
				// #endif
				
				let params = {
					method:'api/v2/distributor/get_shop_code',
					url:url,
					comefrom:comefrom
				};
				
				uni.showLoading({
					title:'加载中...'
				})
				let res = await this.$http(params);
				uni.hideLoading();
				if(res.status)
				{
					this.invitePath = res.data.path;
					uni.getImageInfo({
						src: this.invitePath,
						success(imgRes) {
							self.imgInfo = imgRes.height
						}
					})
				}
				else
				{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.container{
	width: 100%;
	background: #7230ec;
}
.code-con{
	width: 100%;
	height: 1463rpx;
	background: url("https://xcx.zhilvhulian.com/res/static/images/distribution-shop_code_bg.jpg") no-repeat;
	background-size: cover;
	text-align: center;
}
.share-code{
	width: 700rpx;
	height: 1000rpx;
	margin-top: 70rpx;
	border-radius: 8rpx;
}
</style>
